<!DOCTYPE html>
<!-- saved from url=(0076)http://www.uphsh.com/wap/ef73d9dc381d412f964b99e521c270a6/invoice?userToken= -->
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!--<base href="http://www.uphsh.com:80/">-->


<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta content="telephone=no" name="format-detection">
<meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no">
<title>极速开票</title>
<link type="text/css" href="../../resource/ystfiles/wapcommon.css" rel="stylesheet">
<link type="text/css" rel="stylesheet" href="../../resource/ystfiles/fapiao.css">
<script src="../../resource/ystfiles/jquery180min.js" type="text/javascript"></script>
<script type="text/javascript" src="../../resource/ystfiles/wapcommon.js"></script>
<script src="../../resource/qrcode.js"></script>
	
	
<link rel="stylesheet" href="../../resource/ystfiles/weuimin.css">
<link rel="stylesheet" href="../../resource/ystfiles/example.css">
<script type="text/javascript" src="../../resource/ystfiles/api.js"></script>
<script type="text/javascript" src="../../resource/ystfiles/jweixin1002.js"></script>
<script type="text/javascript" src="../../resource/ystfiles/jweixin1.js"></script>
<script src="../../resource/jquery1.js"></script>
<script src="../../resource/qrcode.js"></script>
<script src="../../resource/jquerybarcode.js"></script>
<script src="../../script/api.js"></script>
<script src="../../resource/ystfiles/qrcode.js"></script>
<script src="../../resource/ystfiles/jquerybarcode.js"></script>
<script type="text/javascript" src="../../script/constants.js"></script>
<script type="text/javascript" src="../../script/aes.js"></script>
<script type="text/javascript" charset="UTF-8" src="../../script/naes.js"></script>
<script type="text/javascript" src="../../script/modeecb.js"></script>
<script type="text/javascript" src="../../script/tmd5.js"></script>
<style>
a.btn {
    width: 60px;
    line-height: 25px;
    display: block;
    text-align: center;
    font-size: 12px;
    background: rgba(51,51,51,0.3);
    color: #fff;
    border-radius: 5px;
}
</style>
</head>

<body>
    <header id="statusBar" style="background: #27a8fa;">
	<div class="header">
        <div class="return">
        	<img src="../../image/back.png" style="left:0" onclick="toindex()" />
        </div>
        <div class="tittle">
    		极速开票
        </div>
    </div>
    </header>
    <div id="contant" style="height: 563px;">
		<div class="bg">
			<div style="width: 50%" class="w50 fl"><img id="show" class="center" src="../../resource/ystfiles/txm.png" style="display: block;"><p class="p1 tc">扫一扫</p></div>
			<div  style="width:50%;margin: 0px auto" class="w50 fl"><img  id="show5"  class="center" src="../../resource/ystfiles/ewm.png" style="display: block"><p class="p1 tc">扫   我</p></div>
		</div>
		<div class="ico_pass clearfix"> <!-- onclick="fplist()" -->
			<div class="fl" style="padding-left:3%; padding-top:12px; width:10%">
		        <img src="../../resource/ystfiles/fp.png" width="18" height="16">
		    </div>
			<p class="fr p2" >我的发票</p>
		</div>
	
		<div>
			<table class="tab">
			  <tbody><tr>
			    <td class="tl">发票数量（张）</td>
			    <td class="tr"><span><input id="number" style="background: transparent;text-align: right" type="text" value="0" readonly="true"></input></span></td>
			  </tr>
			  <tr>
			    <td class="tl">累计金额（元）</td>
			    <td class="tr"><span><input id="amount" style="background: transparent;text-align: right" type="text" value="0.00" readonly="true"></input></span></td>
			  </tr>
			</tbody></table>
		</div>
		<!-- 加载动画 -->
	<div id="loadingToast" style="display:none;">
			<div class="weui-mask_transparent"></div>
			<div class="weui-toast">
				<i class="weui-loading weui-icon_toast"></i>
				<p class="weui-toast__content">数据加载中...</p>
			</div>
		</div>
		
		
		<div id="FP_boxs">

	</div>
		<div style="width: 90%" class="FP_btn" onclick="tjFpxx();">
			<a style="display: inline-block;display: -moz-inline-stack;width: 100%;color: #888;" ><strong style="font-size: 20px;">+</strong>&nbsp;手动添加发票信息</a>
		</div>
		<div style="width: 90%" class="FP_btn" onclick="smtjfpxx();">
			<a style="display: inline-block;display: -moz-inline-stack;width: 100%;color: #888;" ><strong style="font-size: 20px;">+</strong>&nbsp;扫码添加发票信息</a>
		</div>

	</div>
	
	<div  class="shade" style="display: none;"><br><br><br><br><br><br><br><br><br><br><br>
		<div style="height:80%;border: 0 solid #A75A5A;width:320px;border-radius:5px;left: 50%;background-color: #fff;margin: -200px auto 0px -160px;position:fixed;">
			<div style="height:10%;width:100%;padding-top:10px" align="right">
		<i class="weui-icon-cancel shade_div" style="font-weight:bold;color:#333;background-color:#fff;margin-right:10px"></i>
			</div>
			<div id="bcTarget" class="barcodeImg" style="text-align:center"></div>
			<div id="invoiceName" style="text-align: center;width: 100%;margin: 30px auto 0 auto;white-space:normal;"></div>
			<div style="text-align: left;padding-left:30px;width:260px;margin: 10px 0 auto;white-space:normal;">
				<p>名称：<i id="ymc"></i></p>
				<p>税号：<i id="ysh"></i></p>
				<p>地址：<i id="ydz"></i></p>
				<p>电话：<i id="ydh"></i></p>
				<p>开户行：<i id="yyh"></i></p>
			</div><br/>
		</div> 
		<div style="width:100%;text-align:center;position: absolute;bottom: 0;margin-bottom:8px;"><img src="../../image/closeQr.png"/></div>
	</div>
	<script>
	var ll=0;
	var xlist;
	var reflag = "";
	var zfqrno = "";
	function accAdd(num1, num2) {
			        var r1, r2, m;
			        try {
			                r1 = num1.toString().split('.')[1].length;
			        } catch(e) {
			                r1 = 0;
			        }
			        try {
			                r2 = num2.toString().split(".")[1].length;
			        } catch(e) {
			                r2 = 0;
			        }
			        m = Math.pow(10, Math.max(r1, r2));
			        // return (num1*m+num2*m)/m;
			        return Math.round(num1 * m + num2 * m) / m;
			}
	
	function smtjfpxx(){
		var FNScanner = api.require('FNScanner');
		FNScanner.openScanner({
		    autorotation: true
		}, function(ret, err) {
		  setTimeout(function(){
		    console.log(JSON.stringify(ret));
			if(ret.eventType == "success"){
		    	var merid = ret.content.split("&")[4];
		    	var callback = function(ret, err){
			            if(ret.flag=='Y'){
			            var callback = function(ret, err){
					        //console.log(JSON.stringify(ret));
					      if (ret) {
   	   					        if(ret.success==true){
   	   					  		   window.location.reload();
        						}else{
        							api.alert({msg:ret.rst});
        						}
   						    } else {
    						    api.alert({msg:'网络异常'});
    						}
					    }
					    var content = {"openId":$api.getStorage("openid"),"userName":ret.name,"taxCode":ret.kpsh,"address":ret.dzdh,"phoneNumber":"","bankName":ret.khh,"bankNumber":""};
					    apiAjax(JSON.stringify(content),url.bcyhxx,callback);
					}else{
						api.alert({msg:'暂未获取开票信息...'});
					}
			    }
			    var content = {"deviceName":api.deviceName,"openid":$api.getStorage("openid"),"merid":merid};
			    apiAjax(JSON.stringify(content),url.yst,callback);
		    }
		  },500); 	 	
		});
	}
	
		function myfp(){		
		api.openWin({
	        name: 'kpxx',
	        url: '../jskp/Invoice_fpList.html'
        });	
	}
	
	
	
	function fplist(){
		api.openWin({
	        name: 'kpxx',
	        url: '../jskp/Invoice_kpxx.html'
        });
	}
	
	function QRcodeShow(){
		var ip = "0.0.0.0";
		var ipAddr = api.require('ipAddress');
		ipAddr.getIp(
		function(ret, err) {
		    if(ret.status){
		    	ip = ret.ip;
		    }
		});

	
		api.openWin({
	        name: '打开二维码',
	        url: url.dkewm+'?dlPhone=' + $api.getStorage("dl_phone") +'&ip=' + ip +'&deviceID='+$api.getStorage("openid") +'&qr=' + qr
        });
	}
	
	function toindex(){
        api.closeWin();
	}
	
	$("#show1").click(function(){
		if(xlist.length==0){
			api.alert({msg:'您尚未添加发票信息，请先添加！'});
			return;
		}else{
			QRcodeShow();
		}
	  	
	});
	
	$("#show").click(function(){
	
		if(xlist.length==0){
			api.alert({msg:"您尚未添加发票信息，请先添加！"});
			return;
		}else{
			scanQRCode();
		}
		
	});
	
	
	$("#show5").click(function(){
		if(xlist.length==0){
			api.alert({msg:"您尚未添加发票信息，请先添加！"});
			return;
		}else{
			createQrcode();
		}
		
	});
	
	
	$(".shade").click(function(){
	  $(".shade").hide();
	});

	</script>

<script type="text/javascript">
var openid = '';
var defid = $api.getStorage("defid");
var qr = $api.getStorage("qr");
function tjFpxx(){
   api.openWin({
		    name: 'tjxx.html',
		    url: 'tjxx.html'
		});
}
var xlist = null;

		apiready = function(){
		    if(api.systemType == "ios"){
			   document.getElementById("statusBar").style.background = "#298cb4";
			}
		    $api.fixStatusBar( $api.dom('header') );
		    $("#loadingToast").show();
            openid = $api.getStorage('openid');
			var header = $api.byId('jsheader');
			if(api.systemType=='ios'){
				$api.fixIos7Bar(header);
			}

			api.addEventListener({
    				name: 'del_reload'
				}, function(ret, err) {
   				 	window.location.reload();
				});
			api.addEventListener({
    				name: 'edit_reload'
				}, function(ret, err) {
   				 	window.location.reload();
				});
			api.addEventListener({
    				name: 'reload'
				}, function(ret, err) {
   				 	window.location.reload();
				});
        var dl_phone = $api.getStorage("dl_phone");
        var ip = "0.0.0.0";
		var ipAddr = api.require('ipAddress');
		var s = api.connectionType;
	    s = s.toLowerCase();
		ipAddr.getIp(
		function(ret, err) {
			if (ret.status) {
				ip = ret.ip;
			}
		});
		    var callback = function(ret, err){
                //console.log(JSON.stringify(ret));
                if (ret && JSON.stringify(ret) != "[]") {
    			   xlist=ret.xlist;
    			    
	        	for(var i=0;i<xlist.length;i++){

	        		var taxcode=xlist[i].TAXCODE==undefined?"&nbsp;":xlist[i].TAXCODE;
	        		var disc="该信息不支持开具增值税专用发票";
					if(xlist[i].TAXCODE!==undefined &&
							xlist[i].ADDRESS!==undefined &&
							xlist[i].BANK_NAME!==undefined &&
							xlist[i].BANK_NUMBER!==undefined &&
							xlist[i].PHONE_NUMBER!==undefined){
						disc="该信息支持开具增值税专用发票";
					}
					
					  var s = ""; 
					  if(xlist[i].ISGET == 1){
					     s += "<div class=\"FP_box clearfix\" style=\"background: #FF7575;margin-bottom:5px\">"
					         +"<div onclick='showDetail(\""+xlist[i].ID+"\",0)'  class=\"fl\" style=\"width: 70%;padding-bottom:18px;\">";
					  }else{
					     s += "<div class=\"FP_box clearfix\" style=\"background: #27a8fa;\">"
					         +"<div onclick='showDetail(\""+xlist[i].ID+"\",1)'  class=\"fl\" style=\"width: 70%;padding-bottom:18px;\">";
					  }
					    s += "<h6><a style=\"color:#fff \">"+ xlist[i].USERNAME	+"</a></h6>"+
	    					"<p style=\"color:#fff;font-size:12px;font-family:微软雅黑;\" id=\"test\">"+taxcode+"</p></div>"+
	    					"<div class=\"fr\" style=\"margin-top:5px;float:right;font-family: 微软雅黑;\"> ";
						defid = $api.getStorage("defid");
						if(defid=='undefined'||typeof(defid)== "undefined"||defid==null||xlist[i].ID == defid ){
							qr = xlist[i].QR;
							$api.setStorage("defid",xlist[i].ID);
							$api.setStorage("qr",qr) 
							
							s += "<a href=\"javascript:;\" class=\"btn\" onclick=\"\">默认</a><div>"+
							"</div><div class=\"FP_box_hint\">&nbsp;"+disc+"</div></div></div>"
						}else{
							s += "<a href=\"javascript:;\" class=\"btn\" onclick=\"setDefault('" + xlist[i].ID+ "','" + xlist[i].QR + "')\">设置默认</a><div>"+
							"</div><div class=\"FP_box_hint\">&nbsp;"+disc+"</div></div></div>"
						}
						
						if(xlist[i].ISGET == 1){
					     s += "<div style=\"margin-left:10px\">以上为已绑定企业信息</div><div class=\"xian\" style=\"width:100%;border-top:1px solid #ddd\" ></div>";
					  }
	    			 
					$("#FP_boxs").append(s);
					
	        	}
	        	$("#loadingToast").hide();
   			 } else {
   			    $("#loadingToast").hide();
				api.alert({msg:'网络异常'});
   			 }
             
		    }
		    var content = {"openId":openid};
		    apiAjax(JSON.stringify(content),url.hqkpxx,callback);
			
			setTotalOrderInfo();
		}
		
function setTotalOrderInfo(){
	var openid = $api.getStorage("openid");
	var callback = function(ret, err){
            //console.log(JSON.stringify(ret));
            var num = 0;
    	var amount = 0;
    	if(ret){
    	var i;
    		for(i=0;i<ret.length;i++){
    			if(ret[i].FPKJ_MSG=="请求开票:成功"){
    				num = num + 1;
    				amount = accAdd((amount+'') , ret[i].AMOUNT);
    			}
    		}
    		
    		$("#number").val(num);
    		if(isNaN(amount)){
    		  $("#amount").val('0.00');
    		}else{
    		  $("#amount").val(amount);
    		}
    	}else{
    		api.alert({msg:'网络异常!'});
    	}
    }
    var content = {"openid":openid};
    apiAjax(JSON.stringify(content),url.kpxx,callback);
}

function setDefault(_id,qr){
    
	$api.setStorage("defid",_id);
	$api.setStorage("qr",qr);
    window.location.reload();
    
}

function scanQRCode(){
	var FNScanner = api.require('FNScanner');
    FNScanner.openScanner({
      autorotation: true
    }, function(ret, err) {
    setTimeout(function(){
        if (ret) {
           console.log(JSON.stringify(ret));
		  		if(ret.eventType=="success"){
		  		        console.log(1);
		     			var strs = ret.content.split("&");
              	 	 	var parms = "";
              	 	 for(var i=0;i<strs.length;i++){
              	 	     if(strs[i].indexOf("invoiceMerId") == 0){
                		        parms += "&" +  strs[i];
                		    }
                		    if(strs[i].indexOf("terminalId") == 0){
                		        parms += "&" + strs[i];
                		    }
               		 }
               		 if(parms == ""){
               		    api.alert({msg:'没有扫描到相关信息！'});
               		 }else{
               		        console.log("12313:"+parms);
               		        var callback = function(ret, err){
					            console.log(JSON.stringify(ret));
					            $("#loadingToast").hide();
				   			 if (ret) {
				   			 	 if(ret.msg=="OK"){
					           			//window.location.href="<%=basePath %>wx/Pay_success.jsp?msgType=2";
					           			api.alert({msg:'请求开票成功！'});
					           			window.location.reload();
						           	}else{
						           		api.alert({msg:'请求开票失败...'});
						           	}
				   			 } else {
				   			     console.log('服务请求错误,请联系管理员...');
				   			     api.alert({msg:'网络异常'});
				   			 }
						    }
						    var qqr = qr + parms.replace("invoiceMerId","invoicemerid").replace("terminalId","terminalid");
						    console.log("qqr:"+parms);
						    console.log("qqr:"+qqr);
						    var content = {"openid":openid,"qr":qqr};
						    console.log(JSON.stringify(content));
						    apiAjax(JSON.stringify(content),url.fpkj,callback);                                   
                       	  }
                       	 }
   				 } else {
   				     alert(JSON.stringify(err));
   				 }
   		},500); 
    });
}

var parseQuery = function(query){
    var reg = /([^=&\s]+)[=\s]*([^&\s]*)/g;
    var obj = {};
    while(reg.exec(query)){
        obj[RegExp.$1] = RegExp.$2;
    }
    return obj;
};

function showDetail(id,flag){ 
		api.openWin({
	        name: '发票编辑',
	        url: './Invoice_edit.html',
	        pageParam:{
	        	id : id,
	        	flag : flag,
	        	openid : openid
	        }
        });
	}
	
	function createQrcode(){
	 $("#loadingToast").show();
		for(var t=0;t<xlist.length;t++){
			if(xlist[t].QR == qr ){
				var yhzh = "";
				if(xlist[t].BANK_NAME!==undefined )
					yhzh += xlist[t].BANK_NAME;
				if(xlist[t].BANK_NUMBER!==undefined )
					yhzh += xlist[t].BANK_NUMBER;
				$("#loadingToast").hide();
				api.openWin({
					name: 'qrcode',
	                url: './qrCode.html',
					pageParam: {
						ymc:xlist[t].USERNAME,
						ysh:xlist[t].TAXCODE,
						ydz:xlist[t].ADDRESS,
						ydh:xlist[t].PHONE_NUMBER,
						yyh:yhzh,
						qr:qr
				  }
				});
		   }
		  }
		}
		
		function refrenshQr(){
		    var dl_phone = $api.getStorage("dl_phone");
			if (typeof(dl_phone) == "undefined" || dl_phone == "undefined" || "" == dl_phone || dl_phone == null) {
			   alert("登录已过期，请重新登录！");
				abc();
				return;
			}
			var ip = "0.0.0.0";
			var ipAddr = api.require('ipAddress');
			var s = api.connectionType;
		    s = s.toLowerCase();
		    if (s == 'wifi' || s == '3g' || s == '4g' || s == '2g') {
			ipAddr.getIp(
			function(ret, err) {
				if (ret.status) {
					ip = ret.ip;
				}
			});
			for(var t=0;t<xlist.length;t++){
				if(xlist[t].QR == qr ){
				var callback = function(ret, err){
			        //console.log(JSON.stringify(ret));
			        if (ret) {
		    	    zfqrno  = ret.qrNo;
		    	    var zfqrCode = zfqrno+","+qr;
		    		$("#invoiceName").html("");
					var qrcode = new QRCode("invoiceName", {
					    text: zfqrCode,
					    width: 200,
					    height: 200,
					    colorDark : "#000000",
					    colorLight : "#ffffff",
					    correctLevel : QRCode.CorrectLevel.H
					});
				    }else {
				    $("#loadingToast").hide();
				    api.alert({msg:'网络异常'});
				    }
			    }
			    var content = {"dlPhone":dl_phone,"ip":ip,"deviceID":$api.getStorage("openid")};
			    apiAjax(JSON.stringify(content),url.kpqr,callback);
			   }
			  }
			} else {
				      $api.toast('提示', '网络异常', 2000);
		    }	
		}
		
</script>



</body></html>